import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import login from '@/components/login'
import register from '@/components/register'
import Find_password from '@/components/Find_password'
import User from '@/components/User'
import Adduser from '@/components/Adduser'
import Commpany from '@/components/Commpany'
import Edituser from '@/components/Edituser'
import Surepassword from '@/components/Surepassword'
import Oneuser from '@/components/Oneuser'
import Tags from '@/components/Tags'
import Taginfo from '@/components/Taginfo'
import Gtype from '@/components/Gtype'
import Atype from '@/components/Atype'
import Uptype from '@/components/Uptype'
import edittag from '@/components/edittag'
import Addtomer from '@/components/Addtomer'
import Showcom from '@/components/Showcom'
import editcomm from '@/components/editcomm'
import Addorder from '@/components/Addorder'
import orderlist from '@/components/orderlist'
import sendgood from '@/components/sendgood'
import orderinfo from '@/components/orderinfo'
import accpect from '@/components/accpect'
import analysis from '@/components/analysis'
import dashboard from '@/components/dashboard'
import gettemp from '@/components/gettemp'
Vue.use(Router)

var routes = [
        {
          path:'/',
          name:'index',
          component:index,
          beforeEnter: (to, from, next) => {
              if (localStorage.getItem('username')) {
                    next();
              } else {
                  next('/login')
           }
        },
          children:[
          {
            path:'/user',
            name:'User',
            component:User,
            meta:{
             name:'用户信息'
            }
          },
           {
            path:'/adduser',
            name:'Adduser',
            component:Adduser,
            meta:{
             name:'添加用户'
            }
          },{
            path:'/commpany',
            name:'Commpany',
            component:Commpany,
            meta:{
             name:'公司信息'
            }
          },{
            path:'/edit_user',
            name:'Edituser',
            component:Edituser,
            meta:{
             name:'编辑用户'
            }
          },{
            path:'/one_user',
            name:'Oneuser',
            component:Oneuser,
            meta:{
             name:'编辑用户'
            }
          },{
            path:'/tag_info',
            name:'Taginfo',
            component:Taginfo ,
            meta:{
             name:'标签信息'
            }
          },{
            path:'/add_tag',
            name:'Tags',
            component:Tags ,
            meta:{
             name:'添加标签'
            }
          },{
            path:'/type_info',
            name:'Gtype',
            component:Gtype ,
            meta:{
             name:'类型信息'
            }
          },
          {
            path:'/add_type',
            name:'Atype',
            component:Atype ,
            meta:{
             name:'添加类型'
            }
          },{
            path:'/up_type',
            name:'Uptype',
            component:Uptype ,
            meta:{
             name:'修改类型'
            }
          },{
            path:'/edit_tag',
            name:'edittag',
            component:edittag,
            meta:{
             name:'修改标签'
            }
          },
          {
            path:'/add_com',
            name:'Addtomer',
            component:Addtomer,
            meta:{
             name:'添加客户'
            }
          },{
            path:'/show_com',
            name:'Showcom',
            component:Showcom,
            meta:{
             name:'展示客户信息'
            }
          },{
            path:'/edit_commster',
            name:'editcomm',
            component:editcomm,
            meta:{
             name:'修改客户信息'
            }
          },
          {
            path:'/add_order',
            name:'Addorder',
            component:Addorder,
            meta:{
             name:'添加订单'
            }
          },{
            path:'/order_list',
            name:'orderlist',
            component:orderlist,
            meta:{
             name:'订单列表'
            }
          },{
            path:'/send_good',
            name:'sendgood',
            component:sendgood,
            meta:{
             name:'发货'
            }
          },{
            path:'/order_info',
            name:'orderinfo',
            component:orderinfo,
            meta:{
             name:'订单信息'
            }
          },
          {
            path:'/accpect',
            name:'accpect',
            component:accpect,
            meta:{
             name:'收货'
            }
          },{
            path:'/analysis',
            name:'analysis',
            component:analysis,
            meta:{
             name:'物流线路分析'
            }
          },{
            path:'/dashboard',
            name:'dashboard',
            component:dashboard,
            meta:{
             name:'总览'
            }
          },{
            path:'/gettemp',
            name:'gettemp',
            component:gettemp,
            meta:{
             name:'展示温度'
            }
          },








          ]
    

        }, 
        {
          path:'/login',
          name:'login',
          component:login,
          meta:{
            name:'登录'
          }
        },
        {
          path:'/register',
          name:'register',
          component:register,
          meta:{
            name:'注册'
          }
        },
        {
          path:'/find_password',
          name:'Find_password',
          component:Find_password,
          meta:{
            name:'找回密码'
          }
        },
         {
          path:'/surepassword',
          name:'Surepassword',
          component:Surepassword,
          meta:{
            name:'确认'
          }
        },
      
       
        
]

export default new Router({
  routes:routes,
  mode:'history'   /*hash*/
})




// // 异步挂载的路由
// // 动态需要根据权限加载的路由表
// export const asyncRouterMap = [
//   {
//     path: '/permission',
//     // name: 'permissionhome',
//     meta: {
//       title: 'permission',
//       icon: 'el-icon-setting',
//       roles: ['admin']
//     },
//     component: resolve => require(['../components/common/Home.vue'], resolve),
//     children: [
//       {
//         name: 'permission',
//         path: '/permission',
//         meta: {
//           title: 'permission', icon: 'el-icon-menu', roles: ['admin']
//         },
//         component: resolve => require(['../components/page/permission.vue'], resolve)
//       }
//     ]
//   },
//   { path: '*', redirect: '/404', hidden: true }
// ]